angular.module('app.baseinfo')

    .factory('materialService', ["$http", "config", function ($http, config) {

        var baseUrl = config.baseUrl;

        var ret = {};

        ret.addMaterial=function(material){
            var url=baseUrl+"/materials";
            return $http.post(url,material);
        };

        ret.getMaterials=function(query){
            var url=baseUrl+"/materials";
            return $http.get(url,{params:query});
        };

        ret.updateMaterial=function(material){
            var url=baseUrl+"/materials/"+material.sku;
            return $http.put(url,material);
        };

        ret.deleteMaterial=function(material){
            var url=baseUrl+"/materials/"+material.sku;
            return $http.delete(url);
        };

        ret.getSkuClass=function(){
            var url=baseUrl+"/skuclasses";
            return $http.get(url);
        };

        return ret;
    }]);